<%@ page  contentType="text/html;charset=UTF-8"  %>
<%@page language="java"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8" >
    <title>登录页面</title>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/md5.js"></script>
    <script type="text/javascript">

        window.onload = function () {


            var req = new XMLHttpRequest();

            req.open("POST","${pageContext.request.contextPath}/bookServlet");

            req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");

            req.send("methodName=adminBookList");

            req.onreadystatechange = function () {

                if(req.readyState == 4 && (req.status ==200 || req.status ==304)){
                       var resp =  req.responseText;

                       //把返回的json的字符串   解析为json对象
                        resp = JSON.parse(resp);

                        var list = resp.list;

                        for(var i =0 ; i< list.length;i++ ){
                            var bookTr ="<tr>" +
                                "<td>" + (i+1)+"<td>" +
                                "<td><img width='100px' src='${pageContext.request.contextPath}"+list[i].produceImgUrl+"' /></td>" +
                                "<td>" +list[i].productName +"</td>" +
                                "<td>" +list[i].price +"</td>" +
                                "<td>" +list[i].author +"</td>" +
                                "<td>" +list[i].numbers +"</td>" +
                                "<td>" +list[i].discount +"</td>" +
                                "<td>" +list[i].press +"</td>" +
                                "<td>" +list[i].stateCode.name +"</td>" +
                                "<td><a href='${pageContext.request.contextPath}/bookServlet?methodName=adminBookInfo&id="+list[i].id+"'>编辑</a></td>" +
                                "</tr>";

                                document.getElementById("bookList").innerHTML +=bookTr;
                        }





                }
            }
        }


    </script>

</head>
<body>
<table id="bookList">
    <tr>
        <td>序号</td>
        <td>商品图片</td>
        <td>商品名称</td>
        <td>价格</td>
        <td>作者</td>
        <td>库存</td>
        <td>折扣</td>
        <td>出版社</td>
        <td>状态</td>
        <td>操作</td>
    </tr>


</table>


</body>
</html>
